<%@ page language="java" contentType="text/html; charset=UTF-8"
	import="com.zmht.specedu.vo.Teachbook,com.zmht.specedu.vo.Soundstudy,java.util.*,com.zmht.specedu.rescue.web.form.TeachBookForm"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	/**
	 * @author 谭湘元
	 * @since 2009/04/23
	 */
	 TeachBookForm bookForm = (TeachBookForm)request.getAttribute("teachBookForm");
 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb18030" />
<title>聋校语言学习及矫治系统</title>
<fmt:setBundle basename="PathResource" scope="session" />
<link href="<%=request.getContextPath() %>/<fmt:message key='StylePath' />style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript"
	src="<fmt:message key='datePicker' />WdatePicker.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/<fmt:message key='jquery' />ajaxHelper.js"></script>
	<script type="text/javascript">
		function submitForm1(){
			var tbookName = document.forms[0].tbookName.value.RTrim();
			if(tbookName==""){
				alert("教材名称必须填写！");
				document.forms[0].tbookName.focus();
				return;
			}
			if(document.forms[0].time.value.RTrim()==""){
				alert("时间必须填写！");
				document.forms[0].time.focus();
				return;
			}
			var scoreText = document.forms[0].scoreText.value.RTrim();
			if(scoreText == ""){
				alert("评分目标必须填写！");
				document.forms[0].scoreText.focus();
				return;
			}else{
				 while(scoreText.indexOf("，")!=-1)//寻找每一个中文逗号，并替换
				 {
					 scoreText=scoreText.replace("，",",");
				 }
			}
			var re = new RegExp("^([a-z]+[\\d])$");
			
			var re = new RegExp("^([a-z]+[\\d])$", "");
			if(!re.test(scoreText)){
				alert("评分目标输入必须为字母和数字的组合,多个以逗号分隔！！");
				document.forms[0].scoreText.focus();
				document.forms[0].scoreText.select();
				return;
			}
			var inputs = document.getElementsByTagName("input");
			for(var i=0;i<inputs.length;i++){
				if(inputs[i].type=="file"){
					var value = inputs[i].value;
					if(value==""){
						continue;
					}
					var accept = inputs[i].accept;
					if(accept=="" || accept=="undefine"){
						continue;
					}
					
					var endwith = value.substring(value.lastIndexOf(".")+1);
					if(accept.toLowerCase().indexOf(endwith)< 0){
						var message = inputs[i].message;
						if(message){
							alert(message+" 必须以"+accept+"结尾!");
						}else{
							alert("所选文件必须以"+accept+"结尾!");
						}
						inputs[i].focus();
						return;
					}
				}
			}
			var remark = document.forms[0].remark.value;
			if(remark.length>100){
				alert("描述最多只能输入100个字！");
				document.forms[0].remark.select();
				return;
			}
			document.forms[0].submit();
		}
		function addNewWord(e,obj){
			if(obj.value.length>100){
				e.returnValue = false;
			}
		}
		<%--function finalTypeChanged(currentValue){
			<%
				String[] finalTypes = Teachbook.finalTypes;
				List bookTypes = (List)request.getAttribute("teachBookTypes");
				StringBuffer soundStudyString = new StringBuffer();
				StringBuffer soundRescueString = new StringBuffer();
				for(int x = 0;x<bookTypes.size();x++){
					Soundstudy type = (Soundstudy) bookTypes.get(x);
					if(type.getTbookType().equals(finalTypes[0])){
						soundStudyString.append(type.getId()).append(",").append(type.getName()).append("|");
					}else{
						soundRescueString.append(type.getId()).append(",").append(type.getName()).append("|");
					}
				}
				if(soundStudyString.length()>0) soundStudyString.deleteCharAt(soundStudyString.length()-1);
				if(soundRescueString.length()>0) soundRescueString.deleteCharAt(soundRescueString.length()-1);
			%>
			var idValueString="";
			if(currentValue=="<%=finalTypes[0] %>"){
				idValueString = "<%=soundStudyString.toString()%>";
			}else if(currentValue=="<%=finalTypes[1] %>"){
				idValueString = "<%=soundRescueString.toString()%>";
			}
			if(idValueString=="") return;

			var bookTypeSelect = document.forms[0].tbookType;
			bookTypeSelect.options.length=0;
			var optionValueLabels = idValueString.split("|");
			for(var i=0;i<optionValueLabels.length;i++){
				var valueLabel = optionValueLabels[i].split(",");
				bookTypeSelect.options.add(new Option(valueLabel[1],valueLabel[0]));
			}
			
		}--%>

		function showFile(fileType,fileSubffix){
			var url ="teachBook.do?method=dowloadTeachBookFile&bookID=<c:out value="${teachBookForm.bookId }" />&fileType="+fileType+"&fileSubffix="+fileSubffix;
			openWindow(url,600,600,true,'文件查看');
		}
	</script>
	
</head>

<body  class="bcolor">
<form action="teachBook.do?method=modifyTeachBook" method="post" enctype="multipart/form-data" name="teachBookForm" id="form1">
	<input name="author" type="hidden" value="<c:out value="${teachBookForm.author }"/>"/>
	<input name="bookId" type="hidden" value="<c:out value="${teachBookForm.bookId }"/>"/>
	<input name="useTime" type="hidden" value="<c:out value="${teachBookForm.useTime }"/>"/>
	<input name="finalType" type="hidden" value="<c:out value="${teachBookForm.finalType }"/>"/>
	
  <table cellspacing="0" cellpadding="0" width="99%" align="center" border="0">
	<tbody>
	<tr>
        <td width="7"><img height="38" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_01.gif" width="7" /></td>
        <td background="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_05.gif"><table cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td width="30"><img height="38" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_02.gif" width="30" /></td>
                <td align="left" width="200" background="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_03.gif">&nbsp;<strong>编 辑 教 材</strong></td>
                <td width="59"><img height="38" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_04.gif" width="59" /></td>
                <td>&nbsp;</td>
              </tr>
            </tbody>
        </table></td>
        <td width="8"><img height="38" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_06.gif" width="8" /></td>
    </tr>
    <tr>
		<td background="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_07.gif"><img height="1" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />spacer.gif" width="1" /></td>
        <td bgcolor="#f7fbff">
      <table cellspacing="0" bordercolordark="#ccccff" cellpadding="0" width="100%" bordercolorlight="#ffffff" border="0">
	  	<tbody>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">教材名称：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF"><input name="tbookName" type="text" value="<c:out value="${teachBookForm.tbookName }" />" class="boxcopy2" id="textfield10" maxlength="50" style="width:295px;"/>
                      <span class="STYLE4">*</span></td>
                </tr>
            </table></td>
          </tr>
          <%--<tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">目标类别：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<select name="finalType" class="boxcopy2" id="select4" style="width:120px;" onchange="finalTypeChanged(this.value);">
						<option value="<%=finalTypes[0] %>" <c:if test="${teachBookForm.finalType=='语音学习'}">selected</c:if> ><%=finalTypes[0] %></option>
						<option value="<%=finalTypes[1] %>" <c:if test="${teachBookForm.finalType=='语音矫治'}">selected</c:if> ><%=finalTypes[1] %></option>
                  </select></td>
                </tr>
            </table></td>
          </tr>--%>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">教材类别：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<select name="tbookType" class="boxcopy2" id="select5" style="width:300px;">
						<c:forEach items="${teachBookTypes}" var="typeVar">
							<option value="<c:out value="${typeVar.id }" />" <c:if test="${typeVar.id == teachBookForm.tbookType}">selected</c:if> >
								<c:out value="${typeVar.name }" />
							</option>
						</c:forEach>
                  	</select></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">教材等级：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF"><select name="tbookClass" class="boxcopy2" id="select6" style="width:300px;">
                      <% 
                      		
							String[] teachBookLevels = Teachbook.teachBookLevels;
							for(int i=0;i<teachBookLevels.length;i++){
						%>	
                      <option <%if(bookForm.getTbookClass()!=null && teachBookLevels[i].equals(bookForm.getTbookClass())) out.print("selected");%>><%=teachBookLevels[i] %></option>
						<%
							}
						 %>
                  </select></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">时 间：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<input name="time" type="text" class="boxcopy2" id="textfield18" value="<c:out value="${teachBookForm.time }" />"
						onfocus="new WdatePicker(this,'%Y-%M-%D',true,'whyGreen');"  style="width:295px;" maxlength="4"/> <span class="STYLE4">*</span>
				  </td>
                </tr>
            </table></td>
          </tr>
		  <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">标准教材：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<input name="stardTeach" type="checkbox" id="textfield18" value="1" <c:if test="${teachBookForm.stardTeach==1 }">checked</c:if> />
				  </td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">评分目标：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF"><input name="scoreText" value="<c:out value="${teachBookForm.scoreText }" />" maxlength="40" type="text" class="boxcopy2" id="textfield29"  style="width:295px;"/>
					 <span class="STYLE4">*</span></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">说 明：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF"><textarea name="remark" rows="5" class="boxcopy2" id="textfield30" style="width:295px;" onpropertychange="if(value.length>100) value=value.substr(0,100)"><c:out value="${teachBookForm.remark }" /></textarea> 最多可输入100个字符</td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">汉字文件(*.jpg)：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<input name="chineseFile" type="file" contentEditable="false" class="boxcopy2" id="fileField" style="width:300px;" message="汉字文件" accept="jpg" />
				  	&nbsp;<c:if test="${teachBookForm.hasChineseFile}"><a href="javascript:showFile('chineseFile','<c:out value="${ContextTypeBuilder.jpgSubffix }" />');">查看</a></c:if>
					</td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">口型文件(*.avi)：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<input name="mouthFile" type="file" contentEditable="false" class="boxcopy2" id="fileField2" style="width:300px;" message="口型文件" accept="avi" />
					&nbsp;<c:if test="${teachBookForm.hasMouthFile}"><a href="javascript:showFile('mouthFile','<c:out value="${ContextTypeBuilder.aviSubffix }" />');">查看</a></c:if></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">拼音文件(*.jpg)：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<input name="pinyinFile" type="file" contentEditable="false" class="boxcopy2" id="fileField3" style="width:300px;" message="拼音文件" accept="jpg" />
					&nbsp;<c:if test="${teachBookForm.hasPinyinFile}"><a href="javascript:showFile('pinyinFile','<c:out value="${ContextTypeBuilder.jpgSubffix }" />');">查看</a></c:if>
				 </td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">声音文件(*.wav)：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<input name="soundFile" type="file" class="boxcopy2" contentEditable="false" id="fileField4" style="width:300px;" message="声音文件" accept="wav" />
					&nbsp;<c:if test="${teachBookForm.hasSoundFile}"><a href="javascript:showFile('soundFile','<c:out value="${ContextTypeBuilder.wavSubffix }" />');">查看</a></c:if></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">手势文件(*.avi)：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<input name="signFile" type="file" class="boxcopy2" id="fileField5" contentEditable="false" style="width:300px;" message="手势文件" accept="avi" />
					&nbsp;<c:if test="${teachBookForm.hasSignFile}"><a href="javascript:showFile('signFile','<c:out value="${ContextTypeBuilder.aviSubffix }" />');">查看</a></c:if></td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">图片文件(*.jpg)：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<input name="pictureFile" type="file" class="boxcopy2" contentEditable="false" id="fileField6" style="width:300px;" accept="jpg" />
					&nbsp;<c:if test="${teachBookForm.hasPictureFile}"><a href="javascript:showFile('pictureFile','<c:out value="${ContextTypeBuilder.jpgSubffix }" />');">查看</a></c:if>		
					</td>
                </tr>
            </table></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#a4c9ec" class="fontbot">
                <tr>
                  <td width="15%" height="20" align="right" valign="middle" bgcolor="#e6f0f8">字母文件(*.jpg)：</td>
                  <td height="20" align="left" valign="middle" bgcolor="#FFFFFF">
					<input name="zimuFile" type="file" class="boxcopy2" contentEditable="false" id="fileField7" style="width:300px;" message="字母文件" accept="jpg" />
					&nbsp;<c:if test="${teachBookForm.hasZimuFile}"><a href="javascript:showFile('zimuFile','<c:out value="${ContextTypeBuilder.jpgSubffix }" />');">查看</a></c:if></td>
                </tr>
            </table></td>
          </tr>
			</tbody>
        </table>
          <table cellspacing="1" cellpadding="0" width="100%" bgcolor="#ffffff" border="0">
           <tbody>
                <tr>
                  <td valign="middle" bgcolor="#e6f0f8"><table cellspacing="0" cellpadding="3" width="100%" border="0">
                      <tbody>
			            <tr>
              <td width="50%" height="20" align="right"><a href="javascript:submitForm1();" onfocus="this.blur()"><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />jz_img/xiugai.gif" border="0" /></a>&nbsp;</td>
              <td height="20" align="left">&nbsp;<a href="javascript:document.forms[0].reset();" onfocus="this.blur()"><img src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />gif-02.gif" border="0" /></a></td>
            </tr>
       				 </tbody>
                  </table></td>
                </tr>
           </tbody>
        </table>
		</td>
		<td background="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_09.gif"><img height="1" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />spacer.gif" width="1" /></td>
    </tr>
    <tr>
        <td><img height="22" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_10.gif" width="7" /></td>
        <td background="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_11.gif">&nbsp;</td>
        <td><img height="22" alt="" src="<%=request.getContextPath() %>/<fmt:message key='CommonImagePath' />table_1_12.gif" width="8" /></td>
      </tr>
	</tbody>
  </table>
</form>
</body>
</html>
